package com.hualude.roadsign.controller;

import com.hualude.roadsign.dto.DTRequestDto;
import com.hualude.roadsign.dto.DTResponseDto;
import com.hualude.roadsign.dto.JsonMsgDto;
import com.hualude.roadsign.service.CoverFaultHandleService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by ding on 2017/8/11.
 */
@Controller
@RequestMapping("/rds_coverFaultHandle")
public class CoverFaultHandleController {
    @Resource
    private CoverFaultHandleService coverFaultHandleService;

    @RequestMapping(value = "/getCoverFaultHandle4DT")
    @ResponseBody
    public DTResponseDto getCoverFaultHandle4DT(DTRequestDto dtRequestDto, String actorIds , Integer orgId, Integer coverMaintenanceStatus) {
        DTResponseDto dtResponseDto = new DTResponseDto();
        try {
            dtResponseDto = coverFaultHandleService.getCoverFaultHandle4DT(dtRequestDto,actorIds, orgId,coverMaintenanceStatus);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dtResponseDto;
    }

    @RequestMapping("/addCoverMaintenanceContent")
    @ResponseBody
    public JsonMsgDto addCoverMaintenanceContent(Integer coverFaultId, String coverMaintenanceContent) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(coverFaultHandleService.addCoverMaintenanceContent(coverFaultId, coverMaintenanceContent));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }

    @RequestMapping("/finishCoverMaintenance")
    @ResponseBody
    public JsonMsgDto finishCoverMaintenance(String coverMaintenancePhoto,Integer coverMaintainerId,String coverMaintenanceTime,String coverMaintenanceExplain,Integer coverFaultId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(coverFaultHandleService.finishCoverMaintenance(coverMaintenancePhoto,coverMaintainerId,coverMaintenanceTime,coverMaintenanceExplain,coverFaultId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }

    @RequestMapping("/getCoverFaultHandleList4App")
    @ResponseBody
    public JsonMsgDto getCoverFaultHandleList4App(Integer orgId,Integer coverMaintenanceStatus,String actorIds,Integer count,Integer size) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(coverFaultHandleService.getCoverFaultHandleList4App(orgId, coverMaintenanceStatus, actorIds, count, size));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }

    @RequestMapping("/getCoverReceiptInfo4App")
    @ResponseBody
    public JsonMsgDto getCoverReceiptInfo4App(Integer coverFaultId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(coverFaultHandleService.getCoverReceiptInfo4App(coverFaultId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }
}
